{% extends "common/layout.html" %}
{% block content %}


    {#    <div class="row">#}
    <div class="row">
        <div class="col-sm-10 col-sm-offset-1">
            <div class="row">
                <div class="col-sm-10 ">
                    <h2>模板下载</h2>

                </div>

            </div>
        </div>
    </div>

    <div class="row">
        <!-- Nav tabs -->
        <div class="col-sm-10 col-sm-offset-1" style="margin-top: 30px">

            <ul class="nav nav-pills" role="tablist">
                <li role="presentation" class="active">
                    <a href="#one" aria-controls="one" role="tab" data-toggle="tab">招标模板
                        <span class="badge">{{ num[0] }}</span>
                    </a>
                </li>

                <li role="presentation">
                    <a href="#two" aria-controls="two" role="tab" data-toggle="tab">承建商模板
                        <span class="badge">{{ num[1] }}</span>
                    </a>
                </li>

                <li role="presentation">
                    <a href="#three" aria-controls="three" role="tab" data-toggle="tab">合同模板
                        <span class="badge">{{ num[2] }}</span>
                    </a>
                </li>

                <button type="button" class="btn btn-success" data-toggle="modal"
                        data-target="#exampleModal" style="margin-left: 10px"><span class="glyphicon glyphicon-open"
                                                                                    aria-hidden="true"></span>上传模板
                </button>


            </ul>

            <!-- Tab panes -->
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane active" id="one">
                    <div class="row" style="margin-top: 10px">
                        <row class="data-table">
                            <table class="table table-bordered table-hover">
                                <tr>
                                    <th class="info">模板名称</th>
                                    <th class="info">文件大小</th>
                                    <th class="info">文件类型</th>
                                    <th class="info">上传时间</th>
                                    <th class="info">上传人员</th>
                                    <th class="info">下载文件</th>
                                </tr>
                                {% for item in alldetail[0] %}
                                    <tr>
                                        <th>{{ item.classtwo }}</th>

                                        <th>{{ item.size }}MB</th>
                                        <th>{{ item.type }}</th>
                                        <th>{{ item.created_time }}</th>
                                        <th>{{ item.creater.nickname }}</th>

                                        <th>
                                            <a class="btn btn-warning"
                                               href="{{ item.url }}">查看文件</a>
                                            <a class="btn btn-danger"
                                               href="{{ buildUrl('/template/detaildelete') }}?id={{ item.id }}">删除</a>
                                        </th>
                                    </tr>

                                {% endfor %}
                            </table>
                        </row>


                    </div>

                </div>

                <div role="tabpanel" class="tab-pane" id="two">
                    <div class="row" style="margin-top: 10px">
                        <row class="data-table">
                            <table class="table table-bordered table-hover">
                                <tr>

                                    <th class="info">模板名称</th>
                                    <th class="info">文件大小</th>
                                    <th class="info">文件类型</th>
                                    <th class="info">上传时间</th>
                                    <th class="info">上传人员</th>
                                    <th class="info">下载文件</th>
                                </tr>
                                {% for item in alldetail[1] %}
                                    <tr>
                                        <th>{{ item.classtwo }}</th>
                                        <th>{{ item.size }}MB</th>
                                        <th>{{ item.type }}</th>
                                        <th>{{ item.created_time }}</th>
                                        <th>{{ item.creater.nickname }}</th>

                                        <th>
                                            <a class="btn btn-success"
                                               href="{{ item.url }}">查看</a>
                                            <a class="btn btn-danger" href="{{ buildUrl('/template/detaildelete') }}?id={{ item.id }}">删除</a>
                                        </th>
                                    </tr>

                                {% endfor %}
                            </table>
                        </row>


                    </div>
                </div>

                <div role="tabpanel" class="tab-pane" id="three">
                    <div class="row" style="margin-top: 10px">
                        <row class="data-table">
                            <table class="table table-bordered table-hover">
                                <tr>

                                    <th class="info">模板名称</th>

                                    <th class="info">文件大小</th>
                                    <th class="info">文件类型</th>
                                    <th class="info">上传时间</th>
                                    <th class="info">上传人员</th>
                                    <th class="info">下载文件</th>
                                </tr>
                                {% for item in alldetail[2] %}
                                    <tr>
                                         <th>{{ item.classtwo }}</th>
                                        <th>{{ item.size }}MB</th>
                                        <th>{{ item.type }}</th>
                                        <th>{{ item.created_time }}</th>
                                        <th>{{ item.creater.nickname }}</th>

                                        <th>
                                            <a class="btn btn-success"
                                               href="{{ item.url }}">查看</a>
                                            <a class="btn btn-danger" href="{{ buildUrl('/template/detaildelete') }}?id={{ item.id }}">删除</a>
                                        </th>
                                    </tr>

                                {% endfor %}
                            </table>
                        </row>


                    </div>
                </div>

            </div>

        </div>
    </div>


    <script>
        $('#myTabs a').click(function (e) {
            e.preventDefault()
            $(this).tab('show')
        })
    </script>

    {#    </div>#}





    {#    模态框#}
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog" role="document">
            {#    等待模态#}
            <div class="modal fade" id="loadingModal">
                <div style="width: 200px;height:20px; z-index: 20000; position: absolute; text-align: center; left: 50%; top: 50%;margin-left:-100px;margin-top:-10px">
                    <div class="progress progress-striped active" style="margin-bottom: 0;">
                        <div class="progress-bar" style="width: 100%;"></div>
                    </div>
                    <h5 style="color:black"><strong>正在上传文件，请耐心等待...</strong></h5>
                </div>
            </div>


            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">上传存档文件</h4>
                </div>
                <div class="modal-body">


{#                    <script type="text/javascript">#}
{#                        $(function () {#}
{#                            function objInit(obj) {#}
{#                                return $(obj).html('<option></option>');#}
{#                            }#}
{##}
{#                            var arrData = {#}
{#                                招标模板:#}
{#                                    {#}
{#                                        招标计划: "年度计划,月度计划,周计划",#}
{#                                        招标策划: "",#}
{#                                        澄清答疑: "",#}
{#                                        招标文件: "",#}
{#                                        中标通知书: "",#}
{#                                    },#}
{#                                 承建商模板:#}
{#                                    {#}
{#                                        承建商考察计划: "季度计划",#}
{#                                        资格预审填表: "资格预审表,基本信息调查表,工程业绩表,考察评审表,考察评审汇总表",#}
{#                                        履约评价: "承建商履约评价表,评价汇总表,优秀承建商评优汇总表",#}
{#                                    },#}
{#                                  合同模板:#}
{#                                    {#}
{##}
{#                                    },#}
{##}
{#                            };#}
{#                            $.each(arrData, function (pF) {#}
{#                                $('#classone').append('<option>' + pF + '</option>');#}
{#                            });#}
{#                            $('#classone').change(function () {#}
{#                                objInit('#classtwo');#}
{#                                objInit('#classthree');#}
{#                                $.each(arrData, function (pF, pS) {#}
{#                                    if ($('#classone option:selected').text() == pF) {#}
{#                                        $.each(pS, function (pT, pC) {#}
{#                                            $('#classtwo').append('<option>' + pT + '</option>');#}
{#                                        });#}
{#                                        $('#classtwo').change(function () {#}
{#                                            objInit('#classthree');#}
{#                                            $.each(pS, function (pT, pC) {#}
{#                                                if ($('#classtwo option:selected').text() == pT) {#}
{#                                                    $.each(pC.split(","), function () {#}
{#                                                        $('#classthree').append('<option>' + this + '</option>');#}
{#                                                    })#}
{#                                                }#}
{#                                            })#}
{##}
{#                                        });#}
{#                                    }#}
{#                                })#}
{#                            });#}
{#                        });#}
{#                    </script>#}
                    <input class="form-control" id="uid" name="uid" style="display:none" value="{{ current_user.id }}">


                    <div class="form-group">
                        <label class="control-label">模板类型:</label>
                        <select class="form-control " name="classone" id="classone">
                            <option>请选择</option>
                            <option>招标模板</option>
                            <option>承建商模板</option>
                            <option>合同模板</option>
                        </select>
                    </div>

{#                       <script type="text/javascript">#}
{#                        function showtype() {#}
{#                            var selectValue = $("#classone").find("option:selected").text();#}
{#                            console.log(selectValue);#}
{#                            if (selectValue == '合同模板') {#}
{#                                $("#templateinput").show();#}
{#                                $("#templateselect").hide();#}
{#                                $("#classtwoform").hide();#}
{#                            } else {#}
{#                                $("#templateselect").show();#}
{#                                 $("#templateinput").hide();#}
{#                                  $("#classtwoform").show();#}
{#                            }#}
{#                        }#}
{#                    </script>#}



{#                    <div class="form-group" id="classtwoform">#}
{#                        <label class="control-label">文件类型:</label>#}
{#                        <select class="form-control " name="classtwo" id="classtwo" onchange="showclasstwo()">#}
{#                        </select>#}
{#                    </div>#}
{##}
{#                        <script type="text/javascript">#}
{#                        function showclasstwo() {#}
{#                            var selectValue = $("#classtwo").find("option:selected").text();#}
{#                            console.log(selectValue);#}
{#                            if (selectValue == '招标策划'||selectValue == '澄清答疑'||selectValue == '招标文件'||selectValue == '中标通知书') {#}
{#                                $("#templateselect").hide();#}
{#                            }#}
{#                             else {#}
{#                                $("#templateselect").show();#}
{#                            }#}
{#                        }#}
{#                    </script>#}
{##}
{##}
{##}
{#                       <div class="form-group" id="templateselect" >#}
{#                        <label class="control-label">文件名称:</label>#}
{#                        <select class="form-control " name="classthree" id="classthree">#}
{#                        </select>#}
{#                    </div>#}
{##}
{##}
{##}
{#                         <div class="form-group" id="templateinput" style="display:none">#}
{#                        <label class="control-label">文件名称:</label>#}
{#                        <input class="form-control " name="templatename" id="templaname">#}
{##}
{#                    </div>#}


                    <div class="form-group">
                        <label class="control-label">上传图片:</label>
                        <div id="input">
                            <input id="upload_input" class="admin img-fluid" type="file" multiple="multiple">
                        </div>
                    </div>

                    <div class="modal-footer">
                        <button class="btn btn-success do-upload" enctype="multipart/form-data">确定上传
                        </button>
                    </div>

                </div>
            </div>
        </div>
    </div>



    <script>
        {#编辑赋值#}
        $('#exampleModal').on('show.bs.modal', function (event) {
            var button = $(event.relatedTarget); // Button that triggered the modal
            var id = button.data('name');
            {#var company = button.data('company');#}
            {#var department = button.data('department');#}
            {#var phone = button.data('phone');#}
            {#var role = button.data('role');#}
            {#var uid = button.data('uid');#}

            var modal = $(this)
            {#modal.find('.modal-title').text('New message to ' + recipient);#}
            {#modal.find('.modal-body input').val(recipient)#}
            {#modal.find('.modal-body textarea').val(recipient)#}
            {#document.getElementById("name").value = name;#}
            {#document.getElementById("company").value = company;#}
            {#document.getElementById("department").value = department;#}
            {#document.getElementById("phone").value = phone;#}
            {#document.getElementById("role").value = role;#}
            {#document.getElementById("uid").value = uid;#}
        });
    </script>



{% endblock %}

{% block js %}
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="{{ buildStaticUrl('/js/template/template.js') }}"></script>

{% endblock %}
